<?php

/*

Club forums, post message (club_post.pro.php)

*/
ob_start();
$rank_check = 1;
include "global.inc.php";
$clubrank_check = 1;
include "club.inc.php";

$subject = strip_tags($subject);
$message = strip_tags($message);

if (stripspaces($subject) == "")
{
	die(header(error("club_forums.php?game=$game","Don't leave the subject blank.")));
}
if (stripspaces($message) == "")
{
	die(header(error("club_forums.php?game=$game","Don't leave the message blank.")));
}

$subject = badwords($subject);
$message = badwords($message);
$message = smilies($message);
$message = format($message,"#000000");

mysql_query("INSERT INTO club_forums2 (club,thread,type,author,replies,posted,last,subject,message,game,last_post_by) VALUES ('$clubid','$thread','$type','$userid','0','$timestamp','$timestamp','$subject','$message','$game','$userid')");
$topic_id = mysql_insert_id();
$topic_id2 = $thread;

if ($type == 2)
{
	$get_thread = fetch("SELECT replies FROM club_forums2 WHERE id = '$thread' AND game = '$game'");
	mysql_query("UPDATE club_forums2 SET last = '$timestamp' WHERE id = '$thread' AND game = '$game'");
	mysql_query("UPDATE club_forums2 SET last_post_by = '$userid' WHERE id = '$thread' AND game = '$game'");
	$replies = $get_thread[replies] + 1;
	mysql_query("UPDATE club_forums2 SET replies = '$replies' WHERE id = '$thread' AND game = '$game'");

die(header(error("club_forums.php?game=$game&clubid=$clubid&act=view_topic&topic=$topic_id2","Your reply has been posted.")));
}

die(header(error("club_forums.php?game=$game&clubid=$clubid&act=view_topic&topic=$topic_id","Your message has been posted.")));

?>